#include <iostream>
#include <cstdio>

int trees[10001];

int main(int argc, char const *argv[]){
    int n, m;
    while(scanf("%d %d", &n, &m) != EOF){
        for (int i = 0; i <= n; i++)
            trees[i] = 1;
        for (int i = 0; i < m; i++){
            int min, max;
            scanf("%d %d", &min, &max);
            for (int j = min; j <= max; j++){
                if (trees[j] == 1)
                    trees[j]--;
            }
        }
        int result = 0;
        for (int i = 0; i <= n; i++){
            if (trees[i] == 1)
                result++;
        }
        printf("%d\n", result);
    }
    return 0;
}
